package com.zmn.mcc.business.interfaces.staff.dingtalk;

import com.dingtalk.api.response.OapiSnsGetPersistentCodeResponse;
import com.taobao.api.ApiException;
import com.zmn.common.dto2.ResponseDTO;
import com.zmn.mcc.common.dto.dingtalk.RobotSendGroupMessage;
import com.zmn.mcc.common.dto.dingtalk.SendImageMessage;
import com.zmn.mcc.common.dto.dingtalk.SendImageMessageResult;
import com.zmn.mcc.model.entity.staff.DingTalkLeave;
import com.zmn.mcc.model.entity.staff.dingtalk.DingTalkIdAndMediaId;
import com.zmn.mcc.model.entity.staff.dingtalk.StaffDingTalk;
import java.util.Date;
import java.util.List;

public interface DingTalkService {

    /**
     * 添加钉钉待入职员工
     *
     * @param realName     员工姓名
     * @param mobile       员工电话
     * @param preEntryTime 预期入职时间
     * @return 钉钉生成的员工userId
     * @throws ApiException
     */
    ResponseDTO<String> addDingDingUser(String realName, String mobile, Date preEntryTime) throws ApiException;

    /**
     * 更新员工花名册
     * @param staffDingTalk
     * @return
     * @throws ApiException
     */
    ResponseDTO<String> updateDingDingUser(StaffDingTalk staffDingTalk) throws ApiException;

    /**
     * 描述: 获取钉钉AccessToken
     *
     * @return AccessToken
     * @author tanghongjun
     * @since 2020/5/27
     **/
    String getDingTalkAccessToken() throws ApiException;

    /**
     * 描述: 获取钉钉二维码登录的SnsAccessToken
     * @return AccessToken
     * @author liubodong
     * @since 2020/5/27
     */
    String getSnsAccessToken() throws  ApiException;

    /**
     * 描述: 获取企业AccessToken
     * @return AccessToken
     * @author liubodong
     * @since 2020/5/27
     */
    String getCorpAccessToken() throws  ApiException;

    /**
     * 获取永久访问code
     * @param snsAccessToken
     * @param tmpAuthCode
     * @return
     * @throws ApiException
     */
    OapiSnsGetPersistentCodeResponse getPersistentCode(String snsAccessToken, String tmpAuthCode) throws  ApiException;

    /**
     * 获取用户授权的SNStoken
     * @return
     */
    String getUserSnsToken(String snsToken, String openId, String persistentCode)  throws ApiException;
    /**
     * 根据员工的钉钉ID获取钉钉信息
     *
     * @param userId
     * @return
     * @since 2020/5/27
     */
    StaffDingTalk getDingTalkResultByuserId(String userId) throws ApiException;

    /**
     * 根据员工的钉钉ID获取钉钉信息
     *
     * @param userId         钉钉用户ID
     * @param content        发送内容
     * @return true 发送成功 false 发送失败
     * @since 2020/5/27
     */
    ResponseDTO<Boolean> sendDingTalkWorkRecord(String userId, String content) throws ApiException;

    /**
     * 根据员工的钉钉ID获取离职员工信息
     *
     * @param dTalkId 钉钉用户ID
     * @return
     * @since 2020/5/27
     */
    ResponseDTO<DingTalkLeave> getLeaveStaffMsgByDTalkId(String dTalkId) throws ApiException;

    /**
     * 根据临时授权码获取用户的unionId
     * @param snsToken
     * @return
     */
    String getUnionIdBySnsToken(String snsToken);

    /**
     * 根据unionId获取员工的userId
     * @param unionId
     * @return
     */
    ResponseDTO<String> getUserIdByUnionId(String unionId) throws ApiException;

    /**
     * 根据授权code获取用户id
     * @param authCode
     * @return
     */
    ResponseDTO<String> getUserIdByAuthCode(String authCode);

    /**
     * 通过机器人向指定群发送消息
     *
     * @param message 钉钉机器人发送群消息对象
     * @return  true 发送成功 false 发送失败
     * @author xujie
     * @since 2021/03/22
     */
    ResponseDTO<Boolean> sendMessageToGroupByRobot(RobotSendGroupMessage message);

    /**
     * 发送图片消息
     *
     * @param dingTalkIdAndMediaIdList 发送图片消息对象
     * @return 发送图片消息结果
     * @author xujie
     * @since 2021/04/28
     */
    ResponseDTO<List<SendImageMessageResult>> sendImageMessage(List<DingTalkIdAndMediaId> dingTalkIdAndMediaIdList);
}
